package com.start.common.jackson;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.start.common.enums.StartBaseIntegerEnum;

import java.io.IOException;

public class StartEnumIntegerSerializer extends JsonSerializer<StartBaseIntegerEnum> {
    @Override
    public void serialize(StartBaseIntegerEnum startEnum, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
        if (startEnum == null) {
            return;
        }
        Integer value = startEnum.getValue();
        jsonGenerator.writeNumber(value);
    }
}
